package com.neu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.po.Inventory;
import com.neu.po.ResponseResult;
import com.neu.po.Salesout;
import com.neu.service.GoodsTypeService;
import com.neu.service.InventoryService;
import com.neu.service.SalesoutService;
import com.neu.view.BigType;

@RestController
@RequestMapping("salesout")
public class SalesoutController {

	@Autowired
	private SalesoutService salesoutService;
	
	@Autowired
	private InventoryService inventoryService;
	
	@Autowired
	private GoodsTypeService goodsTypeService;
	
	@RequestMapping("getPaged")
	public ResponseResult getPaged(int pageNum, int pageSize, String keyword) {
		ResponseResult result = new ResponseResult();
		
		result.setData(salesoutService.getPaged(pageNum, pageSize, keyword));
		
		return result;
	}
	
	@RequestMapping("getGoodsType")
	public ResponseResult getGoodsType() {
		ResponseResult result = new ResponseResult();
		
		result.setData(goodsTypeService.getAll());
		
		return result;
	}
	
	@RequestMapping("getGoods")
	public ResponseResult getGoods(int goodstypeid) {
		ResponseResult result = new ResponseResult();
		
		result.setData(goodsTypeService.getByid(goodstypeid));
		return result;
	}
	
	@RequestMapping("getSum")
	public ResponseResult getSum(int goodsid) {
		ResponseResult result = new ResponseResult();
		
		result.setData(inventoryService.getByGoodsId(goodsid));
		return result;
	}
	
	@RequestMapping("insert")
	public ResponseResult getPaged(@RequestBody BigType bigtype) {
		ResponseResult result = new ResponseResult();
		
		result.setData(salesoutService.insertUpdate(bigtype));
		
		return result;
	}
	

}
